//Increment the frame
function _proceedFrame($object)
{	
	//If Moving right
	if ($object.data('direction_') == 'right')
	{
		//If moving right and reached the end.
		if ($object.data('frame_') == ($object.data('numberOfFrames') - 1))
		{
			//If Moving right and reached the end, and pendulum.
			if ($object.data('pendulum') == true)
			{
				$object.data('direction_', 'left');
				//$object.data('frame_', $object.data('frame_') - 1);
			}
			//If Moving right and reached the end, but not pendulum.
			else
			{
				$object.data('frame_', 0);					
			}
		}				
		//If Moving right and not reached the end.
		else
		{
			$object.data('frame_', $object.data('frame_') + 1 );
		}
	}
	//If Moving left
	if ($object.data('direction_') == 'left')
	{
		//If moving left and reached the beginning.
		if ($object.data('frame_') == 0)
		{
			//If Moving left and reached the beginning, and pendulum.
			if ($object.data('pendulum') == true)
			{
				$object.data('direction_', 'right');
				$object.data('frame_', $object.data('frame_') + 1);
			}
			//If Moving left and reached the beginning, but not pendulum.
			else
			{
				$object.data('frame_', $object.data('numberOfFrames') - 1);
			}
		}
		//If Moving left and not reached the beginning.
		else
		{
			$object.data('frame_', $object.data('frame_') - 1 );
		}
	}
	
	$object.css('background-position', (-$object.data('frame_') * parseInt($object.data('frameWidth'))) + 'px 0px');	
}
